# Maintainer: Alexey Kasatkin <alexeikasatkin@gmail.com>
# ArchLinux maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>

_realname=sparsehash
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.2
pkgrel=3
pkgdesc="Library that contains several hash-map implementations, including implementations that optimize for space or speed (mingw-w64)"
arch=("any")
url="https://code.google.com/p/sparsehash"
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('strip' '!libtool')
source=("https://distfiles.macports.org/sparsehash/${_realname}-${pkgver}.tar.gz")
sha256sums=('2ed639a7155607c097c2029af5f4287296595080b2e5dd2e2ebd9bbb7450b87c')

build() {
  [[ -d "${srcdir}"/build-${MINGW_CHOST} ]] && rm -rf "${srcdir}"/build-${MINGW_CHOST}
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
  install -D -m644 ../${_realname}-${pkgver}/COPYING ${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -k check
}
